<?php

 function send($data_soap,$data)
{

//    $send_data['jsonObj'] = base64_encode(json_encode($d));
//    $data_soap  = new \SoapClient('http://118.178.123.161:800/DataReceive.asmx?wsdl');

//    $data=[
//        'sid'=>'28',
//        'gps_time' => "2019-09-06 12:00:01",
//        'paver_layer_id'=>'35',
//        'roller_layer_id'=>'135',
//        'lon'=>'34.123',
//        'lat'=>'13.65',
//        'hi'=>'135',
//        'drct'=>'36',
//        'speed'=>'235',
//        'temperature'=>'123',
//        'vcv'=>'1',
//    ];

//    $rs = $data_soap->__soapCall("PushMachineWorkData", $data );

    $rs = $data_soap ->PushMachineWorkData($data);

    return $rs;

}

$deviceMap=[
    '75'=>'149',
    '76'=>'153',
    '77'=>'171',
    '78'=>'109',
    '79'=>'218',
    '80'=>'150',
    '81'=>'90',
];



$data_soap  = new \SoapClient('http://118.178.123.161:800/DataReceive.asmx?wsdl');
$rds = new redis();
$rds->connect('127.0.0.1');
echo "start..\r\n";
while(1) {
    usleep(10000);
    $d = $rds->rPop('yzgs_gps');
    if ($d) {
	echo date('Y-m-d H:i:s')."  ".$d. "\r\n";
        $dateTime=date('Ymd_H');
        $data = json_decode($d, true);
        if (!isset($deviceMap[$data['sid']])) continue;
        $data['sid'] = $deviceMap[$data['sid']];
        $data['paver_layer_id'] = 'XMC';
        $rsp = send($data_soap, $data);
        var_dump($rsp);
        $stime = date('Y-m-d H:i:s');
        $str = $stime . ":\r\n" . json_encode($data) . "\r\n" . json_encode($rsp) . "\r\n";
        file_put_contents($dateTime.'_gpslog.log', $str, FILE_APPEND);
    }
}
